RladiesBari Hands-on session

Sara Iacozza

RLadies Meetup - 7 Maggio, 2019

Due cose sui dati

  • Dati comportamentali
  • Variabili dipendenti: accuratezza & tempi di reazione
  • 2 x 2 factorial design, within-subject
  • Struttura random: Partecipanti

Carichiamo i dati e diamo un’occhiata

Carichiamo i pacchetti che ci serviranno (install.packages + library)

Strutturiamo i dati!

##   Participant   Block        Trial             SpeakerPhoto 
##  1      : 160   1:3643   Min.   : 1.00   Speaker1.jpg:1797  
##  2      : 160   2:3575   1st Qu.:21.00   Speaker2.jpg:1804  
##  4      : 160            Median :41.00   Speaker3.jpg:1807  
##  5      : 160            Mean   :40.53   Speaker5.jpg:1810  
##  6      : 160            3rd Qu.:61.00                      
##  7      : 160            Max.   :80.00                      
##  (Other):6258                                               
##  Group_Membership       Condition       Accuracy           RTs        
##  Ingroup :3612    matching   :3614   Min.   :0.0000   Min.   :  98.0  
##  Outgroup:3606    mismatching:3604   1st Qu.:1.0000   1st Qu.: 716.0  
##                                      Median :1.0000   Median : 844.0  
##                                      Mean   :0.9417   Mean   : 888.7  
##                                      3rd Qu.:1.0000   3rd Qu.:1015.0  
##                                      Max.   :1.0000   Max.   :2097.0  
## 

Distribuzione Accuracy

Non sembrano esserci molti errori…

Distribuzione RTs

(solitamente skewed)

Distribuzione RTs per condizione

Predicted Hypotheses:

  1. Le persone sono piu’ veloci a rispondere ad un’associazione corretta che incorreta : –> (RTs) matching<mismatching

  2. Le persone son piu’ veloci a rispondere ad un’associazione in-group che out-group : –> (RTs) in-group Group Membership x Condition

Statisticamente parlando…

gif

Semplice regressione lineare

lm(log10(RTs)~GroupMembership*Condition (+ Block))

+ Random effects

lmer(log10(RTs)~GroupMembershipxCondition (+ Block)+ (1+GroupMembershipxCondition|Participant))

Output

Estimate Std. Error t value
(Intercept) 2.9313 0.0098 298.4912
Condition2-1 0.0378 0.0035 10.8673
Group_Membership2-1 0.0289 0.0034 8.5234
Block2-1 -0.0143 0.0020 -7.1211
Condition2-1:Group_Membership2-1 -0.0409 0.0105 -3.9137
  log10(RTs)
Predictors Estimates CI p
(Intercept) 2.93 2.91 – 2.95 <0.001
Condition2-1 0.04 0.03 – 0.04 <0.001
Group_Membership2-1 0.03 0.02 – 0.04 <0.001
Block2-1 -0.01 -0.02 – -0.01 <0.001
Condition2-1:Group_Membership2-1 -0.04 -0.06 – -0.02 <0.001
Random Effects
σ2 0.01
τ00 Participant 0.00
τ11 Participant.Condition2-1 0.00
τ11 Participant.Group_Membership2-1 0.00
τ11 Participant.Condition2-1:Group_Membership2-1 0.00
ρ01 Participant.Condition2-1 0.23
ρ01 Participant.Group_Membership2-1 0.10
ρ01 Participant.Condition2-1:Group_Membership2-1 0.17
ICC Participant 0.40
Observations 6657
Marginal R2 / Conditional R2 0.060 / 0.455

Data Viz (model output)

Da cosa deriva l’interazione?: pairwise comparisons

L’effetto di Condition e’ maggiore con In-group, pero’..

## $emmeans
## Group_Membership = Ingroup:
##  Condition   emmean     SE  df asymp.LCL asymp.UCL
##  matching      2.89 0.0104 Inf      2.87      2.91
##  mismatching   2.95 0.0101 Inf      2.93      2.97
## 
## Group_Membership = Outgroup:
##  Condition   emmean     SE  df asymp.LCL asymp.UCL
##  matching      2.94 0.0100 Inf      2.92      2.96
##  mismatching   2.95 0.0112 Inf      2.93      2.98
## 
## Results are averaged over the levels of: Block 
## Degrees-of-freedom method: asymptotic 
## Results are given on the log10 (not the response) scale. 
## Confidence level used: 0.95 
## 
## $contrasts
## Group_Membership = Ingroup:
##  contrast               estimate      SE  df z.ratio p.value
##  matching - mismatching  -0.0582 0.00600 Inf -9.716  <.0001 
## 
## Group_Membership = Outgroup:
##  contrast               estimate      SE  df z.ratio p.value
##  matching - mismatching  -0.0173 0.00655 Inf -2.649  0.0081 
## 
## Results are averaged over the levels of: Block

Da cosa deriva l’interazione?: pairwise comparisons 2

L’effetto di In-group e’ nei matching trials…

## $emmeans
## Condition = matching:
##  Group_Membership emmean     SE  df asymp.LCL asymp.UCL
##  Ingroup            2.89 0.0104 Inf      2.87      2.91
##  Outgroup           2.94 0.0100 Inf      2.92      2.96
## 
## Condition = mismatching:
##  Group_Membership emmean     SE  df asymp.LCL asymp.UCL
##  Ingroup            2.95 0.0101 Inf      2.93      2.97
##  Outgroup           2.95 0.0112 Inf      2.93      2.98
## 
## Results are averaged over the levels of: Block 
## Degrees-of-freedom method: asymptotic 
## Results are given on the log10 (not the response) scale. 
## Confidence level used: 0.95 
## 
## $contrasts
## Condition = matching:
##  contrast           estimate      SE  df z.ratio p.value
##  Ingroup - Outgroup -0.04938 0.00669 Inf -7.380  <.0001 
## 
## Condition = mismatching:
##  contrast           estimate      SE  df z.ratio p.value
##  Ingroup - Outgroup -0.00848 0.00573 Inf -1.478  0.1393 
## 
## Results are averaged over the levels of: Block

Diagnostics

Diagnostics - bad example

Diagnostics 2

Diagnostics 2 - bad

LM vs LMER

  log10(RTs)
Predictors Estimates CI p
(Intercept) 2.93 2.93 – 2.93 <0.001
Group_Membership2-1 0.03 0.02 – 0.03 <0.001
Condition2-1 0.04 0.03 – 0.04 <0.001
Block2-1 -0.01 -0.02 – -0.01 <0.001
Group_Membership2-1:Condition2-1 -0.04 -0.05 – -0.03 <0.001
Observations 6657
R2 / adjusted R2 0.062 / 0.061

E’ davvero lo stesso?

## $emmeans
## Condition = matching:
##  Group_Membership emmean       SE   df lower.CL upper.CL
##  Ingroup           2.888 0.002558 6652    2.883    2.893
##  Outgroup          2.937 0.002605 6652    2.932    2.942
## 
## Condition = mismatching:
##  Group_Membership emmean       SE   df lower.CL upper.CL
##  Ingroup           2.947 0.002626 6652    2.942    2.952
##  Outgroup          2.955 0.002611 6652    2.949    2.960
## 
## Results are averaged over the levels of: Block 
## Results are given on the log10 (not the response) scale. 
## Confidence level used: 0.95 
## 
## $contrasts
## Condition = matching:
##  contrast           estimate      SE   df t.ratio p.value
##  Ingroup - Outgroup -0.04924 0.00365 6652 -13.488 <.0001 
## 
## Condition = mismatching:
##  contrast           estimate      SE   df t.ratio p.value
##  Ingroup - Outgroup -0.00729 0.00370 6652  -1.969 0.0490 
## 
## Results are averaged over the levels of: Block

Quindi:

Errors

E’ importante evitare errori…

anche se sembrerebbero andare a nostro favore (*)

Risultati:

I dati hanno supportato le nostre ipotesi. 1. I partecipanti hanno classificato piu’ velocemente un’associazione corretta che incorretta.

Risultati 2:

  1. I partecipanti hanno classificato piu’ velocemente un’associazione ingroup che outgrop

Risultati 3:

E l’interazione dice che c’e’ una differenza tra le condizioni di matching and mismatching per quanto riguarda l’effetto di Group Membership.

Attraverso l’analisi di simple effects (pairwise comparisons), abbiamo visto che i partecipanti erano piu’ veloci con le associazioni in-group ma solo quando un’associazione era corretta.

Take-home messagge:

I mixed-effect models sono importantissimi quando ci sono intra e inter variabilita’ perche’ aiutano a ridurre la possibilita’ di attribuire importanza a cio’ che non ne ha.

GRAZIE MILLE!

Questions?